<?php

class Enterprise extends Node
{

    protected $fiscal_id;
    protected $name;
    protected $commercial_name;
    protected $parent;

    function handleGET( Event $e )
    {
        if ( $e->tag == 'entrar' ) {
            //$roles=User::getLogged()->getRoles();
            //intento ponerme TODOS LOS ROLES POSIBLES PARA ESTA EMPRESA
            $roles = array( );

            // $roles['ADM_ENT']=array($this->id);
            $roles[ 'USR_ENT' ] = array( $this->id );

            $projects = MyLink::$default->get_rows( 'SELECT id FROM milestones WHERE project=id AND enterprise=' . $this->id,
                            true )->toArray();

            $roles[ 'ADM_PRO' ] = $projects;
            $roles[ 'USR_PRO' ] = $projects;

            User::getLogged()->useRoles( $roles ); //el sistema me pondrá solo aquellos a los que puedo acceder

            $_SESSION[ 'enterprise' ] = $this->id;
            Node::$root = Node::getInstance( 'enterprise_main', $this->id );
        }
        else parent::handleGET( $e );
    }

}

?>
